using System;

namespace FineCollection.Intf
{
    /// <summary>
    /// Comparable key and value pair.
    /// </summary>
    /// <typeparam name="K">type of a key (comparable).</typeparam>
    /// <typeparam name="V">type of a value.</typeparam>
    /// <seealso cref="RMap{K,V}"/>
    public class ComparableMapEntry<K,V> : MapEntry<K,V>, IComparable<ComparableMapEntry<K,V>>
        where K: IComparable<K>
    {

        public ComparableMapEntry(K key, V value) 
            : base(key, value)
        {}


        public int CompareTo(ComparableMapEntry<K,V> that)
        {
            if (that == null)
                throw new ArgumentNullException();
            if (that.Key == null)
                throw new ArgumentNullException();

            return this.Key.CompareTo(that.Key);
        }
    }
}